global without sharing class InstrumentConfirmationHandler {
    
    
    /*
    ///发通知给助理
    public static void sendTask(List<InstrumentConfirmation__c> inlist ){
    	
        Map<String,User> accSet = new Map<String,User >();

        for (InstrumentConfirmation__c inl  :inlist ) {
            
            accSet.put(inl.Account__c,null);

        }
        Map<String,String >  accName = new Map<String,String>();
        for (Account acc   :[select Id,Name , OwnerId,Owner.Name  from Account  where Id in: accSet.keySet() and Owner.IsActive = true ] ) {
                
            accSet.put(acc.Id, new User(Id=acc.OwnerId ,UserName =acc.Owner.Name ));
            accName.put(acc.Id , acc.Name);

        }
    
        //// XXX您好，XXX客户的仪器已在完成（不需要安装的仪器）出库，请及时确认是否需生成仪器资产，如果未及时确认，无法纳入仪器绩效，请尽快确认！


        User u = [select Id from User where IsActive=true and   EmployeeNumber =:Label.DuplicatedEquipmentNotiAdmin limit 1];
        List<Task>tList = new List<Task>();
    	for (InstrumentConfirmation__c inc: inlist) {
    		
    			Task t1 = new Task();
    			User owner = accSet.get(inc.Account__c);

    		 	t1.OwnerId = owner == null ? u.Id : owner.Id ;

                t1.WhatId =inc.Id ;

                t1.Description  =  owner == null  ? '仪器出库生成资产确认!客户('+inc.Account__c+')的所有人对应销售员可能已离职!请维护并新建任务!'  : owner.UserName + '您好，'+accName.get(inc.Account__c)+'的仪器已在完成（不需要安装的仪器）出库，请及时确认是否需生成仪器资产，如果未及时确认，无法纳入仪器绩效，请尽快确认！';
                t1.Priority = 'Normal';
                t1.ActivityDate = Date.valueOf(System.now()).addDays(1);
                t1.Subject =   owner.UserName + '您好，'+accName.get(inc.Account__c)+'的仪器已在完成（不需要安装的仪器）出库，请及时确认是否需生成仪器资产，如果未及时确认，无法纳入仪器绩效，请尽快确认！';
                tList.add(t1);
    	}

    	if(tList.size()>0)insert tList;


    }
    ///确认生成资产
    WebService static String generateEquipment(String inf,Boolean flag  ){
    	InstrumentConfirmation__c icf = null ; 
    	try {

    		icf = [select Id ,OpponentSpecialTeam__c,EquipmentType__c,Supplier__c,WhetherComfirm__c,ConfirmTime__c, 

    		ExWarehouse__c,EndDate__c,WhetherStandalone__c,OpponentStatus__c,OpponentDept__c,EnterWay__c,Account__c,

    		(select Id,IMEINumber__c,Product__c from InstrumentConfirmation1Yjn__r ) 

    		from InstrumentConfirmation__c where Id=:inf];

    	}catch (Exception e) {
    	    
    	    return  '仪器确认Id不存在:'+inf;
    	}
    	if(icf.WhetherComfirm__c == '是'){

    		return '已经确认!';
    	}
    	SavePoint sp = Database.setSavepoint();
    	try {
    		if (flag) {
    		
	    		List<Equipment__c> eList = new List<Equipment__c>();
	    	 
		    	for (InstrumentConfirmationD__c d  : icf.InstrumentConfirmation1Yjn__r ) {
		    		
		    		Equipment__c e = new Equipment__c();
		    		e.Account__c =icf.Account__c;
		    		e.Product__c = d.Product__c;

		    		e.IMEINumber__c = d.IMEINumber__c;
		    		e.EndDate__c = icf.EndDate__c;
		    		e.EnterWay__c = icf.EnterWay__c;
		    		e.OpponentDept__c = icf.OpponentDept__c;
		    		e.OpponentStatus__c = icf.OpponentStatus__c;
		    		e.Supplier__c = icf.Supplier__c ;
		    		e.EquipmentType__c = icf.EquipmentType__c ;
		    		e.OpponentSpecialTeam__c = icf.OpponentSpecialTeam__c;
		    		e.InstrumentConfirmation__c = icf.Id ;
		    		eList.add(e);

		    	}


		    	if(eList.size() > 0)insert eList ;

	    	}
	    	icf.WhetherComfirm__c = flag == true ? '是' : '否' ; 
	    	icf.ConfirmTime__c = System.now();

	    	update icf;
	    	if(flag == true)Approval.lock(icf,false);
    	    
    	}catch (Exception e) {

    	    Database.rollback(sp);
    	    return '保存失败!' + e.getMessage()+ e.getStackTraceString();

    	}



    	return 'ok';

    }
    */

}